<template>
  <div class="common-layout">
    <el-container>
      <el-header class="hed"
        >xxxxx大型后台管理系统

        <el-dropdown class="btn" @command="logout">
          <span class="el-dropdown-link">
            欢迎VIP用户:{{store.getters.getUser.username}}
            <el-icon class="el-icon--right">
              <arrow-down />
            </el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item command="a">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </el-header>
      <el-container>
        <el-aside width="200px" class="aside">
          <!-- 侧边栏 -->
          <v-nav />
        </el-aside>
        <el-main>
          <!-- 二级路由出口 -->
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import { ElMessage } from "element-plus";
import { ArrowDown } from "@element-plus/icons-vue";
import { useStore } from "vuex";
import { onMounted } from "vue";
import { useRouter } from "vue-router";
let store = useStore();
let router = useRouter();

// 引入抽离出来的组件 在setup语法糖里面 省略了组件的注册
import vNav from "../components/vNav.vue";

// 退出登录
const logout = (command: string | number | object) => {
  if (command == "a") {
    ElMessage(`click on itme ${command}`);
    // 清空仓库内容/缓存
    store.dispatch("changeUserInfo", false);
    // 退出到登录页面
    router.push("/login");
  }
};

onMounted(() => {
  console.log();
  
});
// let getuser = () =>{
//   store.dispatch("")
// }
</script>

<style lang="less" scoped>
.hed {
  width: 100%;
  height: 60px;
  background: #5f8cc6;
}
.aside {
  height: 600px;
  background: #455e7e;
}
.example-showcase .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
}

.btn {
  position: absolute;
  top: 20px;
  right: 10px;
}
</style>
